package vista;
import com.cloudgarden.layout.AnchorConstraint;
import com.cloudgarden.layout.AnchorLayout;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.BorderFactory;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class PantallaReubicacion extends javax.swing.JFrame {
	private JPanel pnlReubicar;
	private JScrollPane jScrollPane1;
	private JButton btnAceptar;
	private JLabel lblEstanteOPaleta;
	private JTextField txCantidad;
	private JLabel lblCantidad;
	private JComboBox cmbEstanteOPaleta;
	private JComboBox cmbDeposito;
	private JLabel lblDeposito;
	private JPanel pnlReubicarLotes;
	private JLabel lblImagen;
	private JTable tblLotes;
	private JLabel lblTabla;
	private JLabel jLabel1;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				PantallaReubicacion inst = new PantallaReubicacion();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public PantallaReubicacion() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Sistema de Almacen - Reubicación de Productos");
			BorderLayout thisLayout = new BorderLayout();
			getContentPane().setLayout(thisLayout);
			{
				pnlReubicar = new JPanel();
				pnlReubicar.setLayout(null);
				getContentPane().add(pnlReubicar, BorderLayout.CENTER);
				pnlReubicar.setBackground(new java.awt.Color(255,255,255));
				pnlReubicar.setBounds(0, 0, 790, 438);
				{
					jLabel1 = new JLabel();
					pnlReubicar.add(jLabel1, new AnchorConstraint(12, 487, 55, 232, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
					jLabel1.setText("Reubicación de Productos");
					jLabel1.setFont(new java.awt.Font("Bitstream Charter",0,20));
					jLabel1.setBounds(289, 28, 271, 19);
				}
				{
					lblTabla = new JLabel();
					pnlReubicar.add(lblTabla, new AnchorConstraint(14, 768, 53, 494, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL, AnchorConstraint.ANCHOR_REL));
					lblTabla.setText("Seleccione el Lote a Reubicar : ");
					lblTabla.setFont(new java.awt.Font("Bitstream Charter",0,16));
					lblTabla.setBounds(68, 64, 245, 17);
				}
				{
					jScrollPane1 = new JScrollPane();
					pnlReubicar.add(jScrollPane1);
					jScrollPane1.setBounds(68, 107, 684, 189);
					{
						DefaultTableModel tblLotesModel = 
								new DefaultTableModel(
										new String[][] { },
										new String[] { "Producto", "Depósito","Estante","Cantidad de Productos" });
						tblLotes = new JTable();
						jScrollPane1.setViewportView(tblLotes);
						tblLotes.setModel(tblLotesModel);
					}
				}
				{
					lblImagen = new JLabel();
					pnlReubicar.add(lblImagen);
					lblImagen.setBounds(0, 36, 56, 501);
					lblImagen.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagen/fondo7.jpg")));
				}
				{
					pnlReubicarLotes = new JPanel();
					pnlReubicar.add(pnlReubicarLotes);
					pnlReubicarLotes.setBounds(91, 329, 661, 113);
					pnlReubicarLotes.setLayout(null);
					pnlReubicarLotes.setBackground(new java.awt.Color(255,255,255));
					{
						lblDeposito = new JLabel();
						pnlReubicarLotes.add(lblDeposito);
						lblDeposito.setText("Nuevo Depósito :");
						lblDeposito.setBounds(12, 23, 122, 20);
					}
					{
						ComboBoxModel cmbDepositoModel = new DefaultComboBoxModel(new String[] { });
						cmbDeposito = new JComboBox();
						pnlReubicarLotes.add(cmbDeposito);
						cmbDeposito.setModel(cmbDepositoModel);
						cmbDeposito.setBounds(139, 22, 133, 22);
					}
					{
						lblEstanteOPaleta = new JLabel();
						pnlReubicarLotes.add(lblEstanteOPaleta);
						lblEstanteOPaleta.setText("Estante/Paleta :");
						lblEstanteOPaleta.setBounds(308, 26, 130, 15);
					}
					{
						ComboBoxModel cmbEstanteOPaletaModel = 
								new DefaultComboBoxModel(
										new String[] { });
						cmbEstanteOPaleta = new JComboBox();
						pnlReubicarLotes.add(cmbEstanteOPaleta);
						cmbEstanteOPaleta.setModel(cmbEstanteOPaletaModel);
						cmbEstanteOPaleta.setBounds(428, 22, 148, 22);
					}
					{
						lblCantidad = new JLabel();
						pnlReubicarLotes.add(lblCantidad);
						lblCantidad.setText("Cantidad a Reubicar :");
						lblCantidad.setBounds(155, 78, 168, 15);
					}
					{
						txCantidad = new JTextField();
						pnlReubicarLotes.add(txCantidad);
						txCantidad.setBounds(323, 75, 105, 22);
					}
				}
				{
					btnAceptar = new JButton();
					pnlReubicar.add(btnAceptar);
					btnAceptar.setBounds(372, 461, 93, 31);
					btnAceptar.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
					btnAceptar.setIcon(new ImageIcon(getClass().getClassLoader().getResource("imagen/Boton_Aceptar2.jpg")));
					btnAceptar.setRolloverIcon(new ImageIcon(getClass().getClassLoader().getResource("imagen/Boton_Aceptar.jpg")));
					btnAceptar.setActionCommand("Aceptar");
				}
			}
			pack();
			this.setSize(795, 555);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	public void agregarListener (ActionListener accion) {
		btnAceptar.addActionListener(accion);
	}
	
	public void mostrarMensaje(String mensaje){
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	public void cargarListado(AbstractTableModel atm) {
		tblLotes.setModel(atm);
	}

	public int getCantidadFilas() {
		return this.tblLotes.getRowCount();
	}

	public void agregarFilaDeposito(Vector<String> pedido) {
		
		DefaultTableModel modelop = (DefaultTableModel) this.tblLotes.getModel();
		modelop.addRow(pedido);
	}
	
	public String obtenerCodigoDespachoFilaSeleccionada(){
		int fila = tblLotes.getSelectedRow();
		String codPedido = (String) tblLotes.getModel().getValueAt(fila, 0);
		return codPedido;
	}
	
	public int nroFilasSeleccionadas() {
		return tblLotes.getSelectedRowCount();
	}
	
	public void agregarDepositoscmbLinea(String line) {
		DefaultComboBoxModel modelocombo = (DefaultComboBoxModel) cmbDeposito.getModel();
		modelocombo.addElement(line);

	}
	public void agregarEstantesPaletascmbLinea(String line) {
		DefaultComboBoxModel modelocombo = (DefaultComboBoxModel) cmbEstanteOPaleta.getModel();
		modelocombo.addElement(line);

	}

}
